//
//  WoDeEnterTFView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/27.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "WoDeEnterTFView.h"

@implementation WoDeEnterTFView

- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self initSubView];
        [self layout];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.enterTF];
    [_enterTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.right.equalTo(@0).offset(-10);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
}
- (void)initOption{
    
}
- (UITextField *)enterTF{
    if (!_enterTF) {
        UITextField *tf = [[UITextField alloc]init];
        tf.backgroundColor = [UIColor whiteColor];
        tf.text = @"1823000611";
        tf.textColor = TITLECOLOR;
        tf.delegate = self;
        tf.keyboardType = UIKeyboardTypeNumberPad;
        tf.font = [UIFont systemFontOfSize:14];
        [self setTextFiledRightImage:tf image:@"fudao_close-1"];
        _enterTF = tf;
    }
    return _enterTF;
}
-(void)setTextFiledRightImage:(UITextField*)textFiled image:(NSString*)image{
    textFiled.rightViewMode = UITextFieldViewModeAlways;
    UIImageView *paddingView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 0, 16, 16)];
    paddingView.image = [UIImage imageNamed:image];
    paddingView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismissTFText)];
    [paddingView addGestureRecognizer:tap];
    textFiled.rightView = paddingView;
}
- (void)dismissTFText{
    _enterTF.text = @"";
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
    
}
- (void)drawRect:(CGRect)rect{
    
}
@end
